﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Lab_Management_System
{
    /// <summary>
    /// Interaction logic for LoginWindow.xaml
    /// </summary>
    public partial class LoginWindow : Window
    {
        public LoginWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string server = serverTextBox.Text.Trim();
            
            uint port = 0;

            try
            {
                port = Convert.ToUInt32(portTextBox.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid port number.");
                return;
            }
                        
            string database = databaseTextBox.Text.Trim();
            string userId = userIDTextBox.Text.Trim();
            string password = passwordBox.Password.Trim();

            DBConnect conn = new DBConnect(server, port, database, userId, password);
            MessageBox.Show("The users table has: " + conn.Count().ToString() + "entries.");
        }
    }
}
